using System;
using System.Drawing;
using System.Windows.Forms;

using Elev.Core;

namespace Elev.UI.Controls
{
    public class PeriodTabPage : TabPage, IGridManager
    {
        GridControl gridControl;

        public PeriodTabPage()
        {
            BackColor = Color.White;
            Margin = new Padding(0);
            Padding = new Padding(0); 
        }

        public void NavigateTo(int OffsetX, int OffsetY)
        {
            gridControl.NavigateTo(OffsetX, OffsetY);
        }

        #region IGridManage Members

        public void GenerateGrid()
        {
            gridControl = new GridControl((Period)Tag);
            gridControl.RenderGrid();            
            gridControl.Dock = DockStyle.Fill;
            Controls.Add(gridControl);
            
            // Attach this grid to the observer ....
            SelectedStudentObserver.Current.Attach(gridControl);
        }

        public void ReloadGrid()
        {
            SelectedStudentObserver.Current.Detach(gridControl);
            Controls.Remove(gridControl);
            GenerateGrid();
        }

        #endregion
    }
}
